<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>async函数</title>
</head>
<body>
  <script>
    async function main() {
      // 1.如果返回的是一个非Promise类型的数据,状态是成功
      // return 521

      // 2.如果返回的是一个Promise对象,有返回的Promise对象决定状态
      return new Promise((resolve, reject) => {
        resolve('ok')
      })
      // 3.抛出异常
      // throw 'Oh NO'
    }
    let result = main()
    console.log(result)
  </script>
</body>
</html>